<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>flex布局实例</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .main {
            background-color: #000;
            min-height: 200px;
            padding: 10px;
            /* 设置 flex 布局 */
            display: flex;
        }

        .box {
            width: 120px;
            height: 120px;
            background-color: #fff;
            border-radius: 10px;
            padding: 10px;
            margin-right: 10px;
            box-sizing: border-box;
            /* 开启 flex 布局 */
            display: flex;
            /* 设置主轴对齐方式 */
            justify-content: center;
            /* 设置交叉轴对齐方式 */
            align-items: center;
        } 

        .item {
            width: 30px;
            height: 30px;
            border-radius: 50%;
            background-color: #000;
            margin: 10px;
        }

        .box2:nth-of-type(2) {
            flex-direction: column;
        }

        .box3 .item {
            width: 20px;
            height: 20px;
        }

        .box3 .item:nth-of-type(1) {
            align-self: flex-start;
        }

        .box3 .item:nth-of-type(2) {
            align-self: center;
        }

        .box3 .item:nth-of-type(3) {
            align-self: flex-end;
        }
    </style>
</head>
<body>
    <div class="main">
        <div class="box">
            <span class="item"></span>
        </div>

        <div class="box box2">
            <span class="item"></span>
            <span class="item"></span>
        </div>

        <div class="box box3">
            <span class="item"></span>
            <span class="item"></span>
            <span class="item"></span>
        </div>
    </div>
</body>
</html>